/*
 * 项目名称:MySpringMVC
 * 类名称:SysUserController.java
 * 包名称:com.ly.springMVC.controller
 *
 * 修改履历:
 *      日期                修正者      主要内容
 *      2019-03-22 11:16    apple      初版完成
 *
 * Copyright (c) 2017-2019 咨同科技
 */
package com.ly.springMVC.controller;

import com.ly.springMVC.Service.SysUserService;
import com.ly.springMVC.annotation.ZtAutoWired;
import com.ly.springMVC.annotation.ZtController;
import com.ly.springMVC.annotation.ZtRequestMapping;
import com.ly.springMVC.entity.SysUserEntity;

import java.util.Date;
import java.util.List;

/**
 * SysUserController
 *
 * @author apple
 */
@ZtController
@ZtRequestMapping("/user")
public class SysUserController {

    @ZtAutoWired
    private SysUserService sysUserService;

    @ZtRequestMapping("/add")
    public void add() {
        SysUserEntity sysUserEntity = new SysUserEntity("张三", "女", 20);
        sysUserService.add(sysUserEntity);
        System.out.println("时间：" + new Date() + "——增加：" + sysUserEntity.toString());
    }

    @ZtRequestMapping("/delete")
    public void delete() {
        String id = "1";
        sysUserService.delete(id);
        System.out.println("时间：" + new Date() + "——删除：ID = " + id);
    }

    @ZtRequestMapping("/update")
    public void update() {
        SysUserEntity sysUserEntity = new SysUserEntity("小明", "男", 30);
        sysUserService.update(sysUserEntity);
        System.out.println("时间：" + new Date() + "——修改：" + sysUserEntity.toString());
    }

    @ZtRequestMapping("/list")
    public List<SysUserEntity> list() {
        List<SysUserEntity> list = sysUserService.list();
        System.out.println("时间：" + new Date() + "——查看：" + list.toString());
        return list;
    }
}